package com.ynhenc.pta.routeRank;

import java.awt.geom.Point2D;
import java.io.*;
import java.util.*;

import com.jhlabs.map.proj.*;
import com.ynhenc.comm.GisComLib;

public class Wgs84ToTm extends GisComLib {

	public static Vertex getWgs84ToTm(Point2D.Double wgs84) {

		Vertex tm = new Vertex(0, 0);

		getProjection().transform(wgs84, tm);

		if (true) {
			double dx = 185.4170934;
			double dy = -310.3102959;
			tm = new Vertex( tm.getX() + dx, tm.getY() + dy );
		}
		
		if ( true ) {
			GisComLib lib = new GisComLib();
			lib.debug("wgs84:" + wgs84);
			lib.debug("tm:" + tm );
		} 

		return tm;
	} 

	private static Projection getProjection() {
		if (PROJECTION == null) {
			String tm = "cs2cs +proj=latlong +datum=WGS84 +ellps=WGS84 +to +proj=tmerc +lat_0=38N +lon_0=127.0028902777777777776E +ellps=bessel +x_0=200000 +y_0=500000 +k=1.0 +towgs84=-146.43,507.89,681.46";
			String katec = "cs2cs +proj=latlong +datum=WGS84 +ellps=WGS84 +to +proj=tmerc +lat_0=38N +lon_0=128.0E +ellps=bessel +x_0=400000 +y_0=600000 +k=0.9998 +towgs84=-146.43,507.89,681.46";
			String prj = tm;
			PROJECTION = ProjectionFactory.fromPROJ4Specification(prj.split(" "));
		}
		return PROJECTION;
	}

	private static Projection PROJECTION;
}